﻿@using Grand.Core.Domain.Catalog
@model OrderModel.AddOrderProductModel.ProductDetailsModel
@{
    //page title
    ViewBag.Title = string.Format(T("Admin.Orders.Products.AddNew.Title2").Text, Model.Name, Model.OrderNumber);
}
@*we add enctype = "multipart/form-data" because "File upload" attribute control type requries it*@

<form asp-controller="Order" asp-action="AddProductToOrderDetails" asp-route-orderId="@Model.OrderId"
      asp-route-productId="@Model.ProductId" enctype="multipart/form-data" method="post" id="product-details-form">

    
    <div asp-validation-summary="All"></div>
    <vc:admin-widget widget-zone="order_add_products_details_top" additional-data="Model" />
    <div class="row">
        <div class="col-md-12">
            <div class="x_panel light form-fit">
                <div class="x_title">
                    <div class="caption">
                        <i class="fa fa-cubes"></i>
                        @string.Format(T("Admin.Orders.Products.AddNew.Title2").Text, Model.Name, Model.OrderNumber)
                        @Html.ActionLink("(" + T("Admin.Orders.Products.AddNew.BackToList") + ")", "AddProductToOrder", new { orderId = Model.OrderId })
                    </div>
                </div>
                <div class="x_content form">
                    <div class="col-md-offset-1 col-md-11 col-sm-11">
                        @if (Model.Warnings.Count > 0)
                        {
                            <div class="note note-danger">
                                @foreach (var warning in Model.Warnings)
                                {
                                    @warning
                                    <br />
                                }
                            </div>
                        }
                    </div>
                    @if (Model.ProductType == ProductType.SimpleProduct)
                    {
                        <div class="form-horizontal">
                            <div class="form-body">
                                <div class="form-group">
                                    <admin-label asp-for="UnitPriceInclTax" />
                                    <div class="col-md-9 col-sm-9">
                                        <admin-input asp-for="UnitPriceInclTax" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <admin-label asp-for="UnitPriceExclTax" />
                                    <div class="col-md-9 col-sm-9">
                                        <admin-input asp-for="UnitPriceExclTax" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <admin-label asp-for="Quantity" />
                                    <div class="col-md-9 col-sm-9">
                                        <admin-input asp-for="Quantity" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <admin-label asp-for="SubTotalInclTax" />
                                    <div class="col-md-9 col-sm-9">
                                        <admin-input asp-for="SubTotalInclTax" />
                                    </div>
                                </div>
                                <div class="form-group">
                                    <admin-label asp-for="SubTotalExclTax" />
                                    <div class="col-md-9 col-sm-9">
                                        <admin-input asp-for="SubTotalExclTax" />
                                    </div>
                                </div>
                                @{
                                    var dataDict = new ViewDataDictionary(ViewData) { new KeyValuePair<string, object>("productId", Model.ProductId) };
                                    <partial name="_ProductAddAttributes" model="Model.ProductAttributes" view-data="dataDict" />
                                }
                                @{

                                    var dataDictGiftCard = new ViewDataDictionary(ViewData);
                                    dataDictGiftCard.TemplateInfo.HtmlFieldPrefix = "giftcard";
                                    <partial name="_ProductAddGiftCardInfo" model="Model.GiftCard" view-data="dataDictGiftCard" />
                                }
                                <div class="form-actions">
                                    <div class="row">
                                        <div class="col-md-offset-3 col-md-9 col-sm-9">
                                            <div class="note note-info">
                                                <strong>@T("Admin.Orders.Products.AddNew.Note2")</strong>
                                            </div>
                                            <input type="submit" class="k-button" value="@T("Admin.Orders.Products.AddNew")" />
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    }
                    else if (Model.ProductType == ProductType.GroupedProduct)
                    {
                        <div>
                            <div class="note note-info">
                                Grouped products are not currently supported for adding to an existing order
                            </div>
                        </div>
                    }
                    else if (Model.ProductType == ProductType.Reservation)
                    {
                        <div>
                            <div class="note note-info">
                                Reservation products are not currently supported for adding to an existing order
                            </div>
                        </div>
                    }
                    else
                    {
                        <div class="note note-info">
                            This product type (unknown) is not currently supported for adding to an existing order
                        </div>
                    }
                </div>
            </div>
        </div>
    </div>
    <vc:admin-widget widget-zone="order_add_products_details_bottom" additional-data="Model" />
</form>
